package com.sczmgk.hotline.base;

import android.os.Message;

import com.sczmgk.hotline.callback.OnRefreshListener;
import com.sczmgk.hotline.callback.SimplePaserJsonCallback;
import com.sczmgk.hotline.httpUtils.MyHttp;
import com.sczmgk.hotline.utils.MyLog;


/**
 * Created by Administrator on 2017/5/15.
 */

public abstract class ChatBaseActivity<M> extends RefreshAndLoadMoreBaseActivity<M>{
    /**
     * 设置监听
     */
    @Override
    public void setListener() {
        mListView.setOnRefreshListener(new OnRefreshListener() {

            @Override
            public void onPullDownRefresh() {
                MyLog.i(TAG, "下拉刷新----");
                pullDownRefresh();
            }

            @Override
            public void onLoadingMore() {

//                loadMore();
            }
        });


    }


    /**
     * 加载数据
     *
     * @param page
     * @param loadStatus
     */
    @Override
    protected void loadData(final int page, String keyoword, final int loadStatus) {

        MyLog.d(TAG,"加载数据页码："+page);
        MyHttp.request(this, getRquestUrl(), getRequestData(page, keyoword), MyHttp.POST, false, getCacheKey(), new SimplePaserJsonCallback() {
            @Override
            public void onVerifyIsNull() {

            }

            @Override
            public void onVerifySuccess(String dataRaw) {
                dismissLoadingDiaLog();
                paserJson(dataRaw, loadStatus);

                Message msg = Message.obtain();
                msg.what = HIDE_FOOTER_HEADER;
                mHandler.sendMessage(msg);
            }

            @Override
            public void onServerUnKnownError() {

            }

            @Override
            public void onErrorCodeError(String msg) {

                showErrorMsg(msg);
            }
        });

    }

}
